package tr.edu.metu.is.mega.server.entity;

import java.io.Serializable;
import java.sql.Timestamp;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedNativeQueries;
import javax.persistence.NamedNativeQuery;

/**
 * The persistent class for the announcement database table.
 * 
 */
@Entity
@NamedNativeQueries({ @NamedNativeQuery(name = "Announcement.getAnnouncementsToMail", query = "select * from announcement where datecreated between now()-interval '1 hour' and now()", resultClass = Announcement.class), })
public class Announcement implements Serializable, tr.edu.metu.is.mega.server.core.BaseEntity {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer pkid;

    private String announcementtext;

    private String createdby;

    private Timestamp datecreated;

    // bi-directional many-to-one association to Course
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "fk_courseid")
    private Course course;

    /**
     * Default constructor.
     */
    public Announcement() {
    }

    /**
     * Returns pkid.
     * 
     * @return the pkid
     */
    @Override
    public Integer getPkid() {
        return pkid;
    }

    /**
     * Sets pkid value.
     * 
     * @param pkid the pkid to set
     */
    @Override
    public void setPkid(Integer pkid) {
        this.pkid = pkid;
    }

    /**
     * Returns announcementtext.
     * 
     * @return the announcementtext
     */
    public String getAnnouncementtext() {
        return announcementtext;
    }

    /**
     * Sets announcementtext value.
     * 
     * @param announcementtext the announcementtext to set
     */
    public void setAnnouncementtext(String announcementtext) {
        this.announcementtext = announcementtext;
    }

    /**
     * Returns createdby.
     * 
     * @return the createdby
     */
    public String getCreatedby() {
        return createdby;
    }

    /**
     * Sets createdby value.
     * 
     * @param createdby the createdby to set
     */
    public void setCreatedby(String createdby) {
        this.createdby = createdby;
    }

    /**
     * Returns datecreated.
     * 
     * @return the datecreated
     */
    public Timestamp getDatecreated() {
        return datecreated;
    }

    /**
     * Sets datecreated value.
     * 
     * @param datecreated the datecreated to set
     */
    public void setDatecreated(Timestamp datecreated) {
        this.datecreated = datecreated;
    }

    /**
     * Returns course.
     * 
     * @return the course
     */
    public Course getCourse() {
        return course;
    }

    /**
     * Sets course value.
     * 
     * @param course the course to set
     */
    public void setCourse(Course course) {
        this.course = course;
    }

}
